﻿using RPAVIEW.util;
using RPAVIEW.views.controlLibrary;
using System.Windows.Controls;

namespace RPAVIEW.views.EditPage.flows.LoopExcelN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.loopObject.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.loopType.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.startRow.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.startColumn.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.endRow.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.endColumn.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.sheetName.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.readShowContent.GetBindingExpression(CheckBox.IsCheckedProperty).UpdateSource();
            this.trimContent.GetBindingExpression(CheckBox.IsCheckedProperty).UpdateSource();
        }

        private void LoopTypeChanged(object sender, SelectionChangedEventArgs e) {
            int loopType = this.loopType.SelectedIndex;
            FlowEditWindow window = WindowUtil.GetWindow<FlowEditWindow>();
            Output outPutPage = window.General.output.Children[0] as Output;
            outPutPage.indexLabel.Content = "当前行号保存至：";
            switch (loopType) { 
                case 0: { 
                    //已使用区域
                    ElementUtil.HideRow(this.beginTiprow);
                    ElementUtil.HideRow(this.endTiprow);
                    ElementUtil.HideRow(this.rowrow);
                    ElementUtil.HideRow(this.columnrow);
                    ElementUtil.HideRow(this.endrowrow);
                    ElementUtil.HideRow(this.endcolumnrow);
                    break;    
                } 
                case 1: { 
                    //区域
                    ElementUtil.ShowRow(this.beginTiprow);
                    ElementUtil.ShowRow(this.rowrow);
                    ElementUtil.ShowRow(this.columnrow);
                    ElementUtil.ShowRow(this.endTiprow);
                    ElementUtil.ShowRow(this.endrowrow);
                    ElementUtil.ShowRow(this.endcolumnrow);
                    break;    
                } 
                case 2: {
                    //行
                    ElementUtil.HideRow(this.beginTiprow);
                    ElementUtil.ShowRow(this.rowrow);
                    ElementUtil.HideRow(this.columnrow);
                    ElementUtil.HideRow(this.endTiprow);
                    ElementUtil.ShowRow(this.endrowrow);
                    ElementUtil.HideRow(this.endcolumnrow);
                    break;    
                } 
                case 3: { 
                    //列
                    ElementUtil.HideRow(this.beginTiprow);
                    ElementUtil.HideRow(this.rowrow);
                    ElementUtil.ShowRow(this.columnrow);
                    ElementUtil.HideRow(this.endTiprow);
                    ElementUtil.HideRow(this.endrowrow);
                    ElementUtil.ShowRow(this.endcolumnrow);
                    outPutPage.indexLabel.Content = "当前列名保存至：";
                    break;    
                } 
                default: break;
            }
        }
    }
}
